package com.fr.data.core.db.dialect;

import com.fr.base.StringUtils;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class MSSQL2005Dialect extends MSSQL2000Dialect
{
  public String columnType2SQL(int paramInt, String paramString)
  {
    switch (paramInt)
    {
    case 2004:
      return "image";
    case 91:
      return "datetime";
    case 92:
      return "datetime";
    case 93:
      return "datetime";
    case 8:
      return "float";
    case -7:
      return "varchar(1)";
    case 2005:
      return "varchar";
    case 4:
      return "int";
    case 12:
      return "varchar(" + paramString + ")";
    case -3:
      return "varchar(" + paramString + ")";
    case 7:
      return "float";
    case -6:
      return "smallint";
    case 3:
      return "decimal(" + paramString + ")";
    case 2:
      return "numeric(" + paramString + ")";
    case 1:
      return "char(" + paramString + ")";
    case -1:
      return "nvarchar";
    case -4:
      return "varbinary";
    case -2:
      return "binary(" + paramString + ")";
    }
    return TypeUtils.getTypeName(paramInt);
  }

  public String[] getSchemas(Connection paramConnection)
    throws Exception
  {
    DatabaseMetaData localDatabaseMetaData = paramConnection.getMetaData();
    ArrayList localArrayList = new ArrayList();
    if (!(StringUtils.isBlank(localDatabaseMetaData.getSchemaTerm())))
    {
      Statement localStatement = paramConnection.createStatement();
      ResultSet localResultSet = localStatement.executeQuery("select name from sys.schemas;");
      while (localResultSet.next())
        localArrayList.add(localResultSet.getString(1).trim());
    }
    return ((String[])localArrayList.toArray(new String[localArrayList.size()]));
  }
}